home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Hardware / AV Tools / VUMeters / Sources / VUMeters.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-27  |  5.0 KB  |  164 lines  |  [TEXT/KAHL]

  1. /*
  2.  *                  ARTA VUMeters for Macintosh
  3.  *                      Malcolm Slaney
  4.  *                 Advanced Technology Group
  5.  *                Apple Computer, Inc.
  6.  *                 malcolm@apple.com
  7.  *                     1992-1993
  8.  *
  9.  *    Warranty Information
  10.  *    Even though Apple has reviewed this software, Apple makes no warranty
  11.  *    or representation, either express or implied, with respect to this
  12.  *    software, its quality, accuracy, merchantability, or fitness for a 
  13.  *    particular purpose.  As a result, this software is provided "as is,"
  14.  *    and you, its user, are assuming the entire risk as to its quality
  15.  *    and accuracy.
  16.  *
  17.  *    Copyright (c) 1992-1993 by Apple Computer, Inc
  18.  *        All Rights Reserved.
  19.  */
  20. #include    <QDOffscreen.h>
  21. #include    <Picker.h>
  22.  
  23. #define    NIL_POINTER        (void *)0
  24. #define    NO_FLAGS        0L
  25. #define    NULL_STRING        "\p"
  26. #define    NIL_STRING        "\p"
  27. #define    MOVE_TO_FRONT        -1L
  28. #define    SCROLL_BAR_SIZE        15
  29. #define    REMOVE_ALL_EVENTS    0
  30. #define    MIN_SLEEP        0L
  31. #define    NIL_MOUSE_REGION    0L
  32. #define    DRAG_THRESHOLD        30
  33.  
  34. #define    LEAVE_WHERE_IT_IS    FALSE
  35. #define    NORMAL_UPDATES        TRUE
  36.  
  37. #define    SCALE_FONT_NUMBER    1        /* Font for labeling meter */
  38. #define    SCALE_FONT_SIZE        9        /* Font size for meter label */
  39. #define    SCALE_DEGREES        150        /* Total angle of scale travel */
  40. #define    SCALE_OVERLOAD_DELTA    10        /* Offset from corner for light */
  41. #define    SCALE_OVERLOAD_SIZE    5        /* Size of indicator */
  42.  
  43. #define    DEFAULT_SCREEN_DEPTH    0        /* Set to 0 so NewGWorld will pick best */
  44.  
  45.                         /* As a percentage of needle length */
  46. const float kTickStart = .9;            /* Inner Radius of ticks */
  47. const float kTickMiddle = .95;            /* For Short Ticks */
  48. const float kTickEnd = 1.0;            /* Outer Radius */
  49.  
  50. enum channelNum { kLeftChannel = 0, kRightChannel = 1, kMaxChannel = 2, kBothChannel};
  51. enum portNum {kInputPort = 0, kOutputPort = 1};
  52. enum levelNum {kPeakReading = 0, kPowerReading = 1};
  53. enum speedNum {kFastSpeed = 0, kNormalSpeed = 1};
  54. enum referenceNum {kFullScaleReference = 0, kAnalogLineReference = 1};
  55.  
  56.                         /* A generic piece of a window with
  57.                          * its own offscreen GWorld and a
  58.                          * rect to tell me where to put it.
  59.                          */
  60. class CWindowPiece {
  61. protected:
  62.     GWorldPtr    fOffScreenWorld;
  63.     Rect        fWindowRect;
  64.     WindowPtr    fWindow;
  65.     RgnHandle    fDirtyScreenRegion;    /* Portion of screen that needs updating */
  66.  
  67. public:
  68.     void        IWindowPiece();
  69.     void        CopyToWindow();
  70.     void        Erase();
  71.     void        SetWindowRect(Rect *screenRect, Rect *windowRect);
  72.     void        SetWindow(WindowPtr);
  73.     void        Update();
  74.     void        Dispose();
  75. };
  76.  
  77.                         /* One VU Meter.  This is actually
  78.                          * implemented as a CWindowPiece so
  79.                          * this class tells how to draw the
  80.                          * background scale into an offscreen
  81.                          * bitmap and how to copy the scale and
  82.                          * the needle into the window.  A window
  83.                          * that is showing two VU meters will
  84.                          * have two instances of this class.
  85.                          */
  86. class CVUMeter: public CWindowPiece {
  87. protected:
  88.     float        fLastReading;
  89.     float        *fCurrentReading;    /* Pointer to left and right readings */
  90.     float        *fChannelGainPointer;    /* External gain factor to include */
  91.     GWorldPtr    fScaleWorld;
  92.     Point        fMeterCenter;
  93.     int        fScaleLength;        /* Computed by SetWindowRect() */
  94.     enum channelNum    fChannelIndicator;
  95.     enum portNum    fPortType;
  96.     enum levelNum    fLevelType;
  97.     enum speedNum    fSpeedType;
  98.     enum referenceNum fReferenceType;
  99.     RgnHandle    fDirtyScaleRegion;    /* Portion of scale that needs updating */
  100.     short        fOverload;        /* Is the overload light lit? */
  101.     Rect        fOverloadRect;        /* Position of overload light */
  102.     
  103. public:
  104.     void        IVUMeter(enum portNum portType, enum channelNum channelIndicator, 
  105.                     enum levelNum readingType, enum speedNum speedType,
  106.                     enum referenceNum referenceType);
  107.     void        SetMeterParms(Rect *windowRect);
  108.     void        DrawScale();
  109.     void        DrawNeedle();
  110.     void        UpdateLevel();
  111.     void        RefreshLevel();
  112.     void        GetExternalGain();
  113.     void        SetWindowRect(Rect *screenRect, Rect *windowRect);
  114.     void        Dispose();
  115.     int        AllMemoryAllocated();
  116. };
  117.  
  118. class CPictureMeter: public CVUMeter {
  119. private:
  120.     PicHandle    fPicture;
  121. public:
  122.     void        IVUMeter(enum portNum portType, enum channelNum channelIndicator, 
  123.                     enum levelNum readingType, enum speedNum speedType,
  124.                     enum referenceNum referenceType);
  125.     void        SetMeterParms(Rect *windowRect);
  126.     void        DrawScale();
  127. };
  128.                         /* A window showing one or two VU
  129.                          * meters corresponding to one point
  130.                          * in the signal flow patch bay.
  131.                          */
  132. class CPortWindow {
  133. protected:
  134.     enum portNum    fPortType;
  135.     enum channelNum    fChannel;
  136.     enum levelNum    fLevelType;
  137.     enum speedNum    fSpeedType;
  138.     enum referenceNum fReferenceType;
  139.     CVUMeter    *fFirstMeter;
  140.     CVUMeter    *fSecondMeter;
  141.     WindowPtr    fWindow;
  142.     
  143. public:
  144.     void        IPortWindow();
  145.     void        NewWindow();
  146.     void        UpdateWindowType();
  147.     void        UpdateWindowSize();
  148.     void        UpdateLevel();
  149.     void        RedrawWindow();
  150.     void        RefreshWindow();
  151.     void        SetUpMenus();
  152.     void        Update();
  153.     void        Dispose();
  154.     int        AllMemoryAllocated();
  155.     WindowPtr    GetWindow();
  156. };
  157.  
  158. extern int IsMemoryAvailable(long memoryRequest);
  159. long MemoryNeededForNewWindow(Rect *screenRect);
  160. void DoCautionAlert(short messageNumber);
  161. void DoStopAlert(short messageNumber);
  162. void ShowValue(short messageNumber, long val);
  163.  
  164.